package vashion.azeroth.api.controller.tran;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import vashion.azeroth.api.controller.base.BaseController;
import vashion.azeroth.common.tran.transfer.OrderTransfer;
import vashion.azeroth.contant.TranErrorEnum;
import vashion.azeroth.core.personal.pojo.PersonalMember;
import vashion.azeroth.core.personal.tran.pojo.PersonalDisburse;
import vashion.azeroth.core.result.ApiResult;
import vashion.azeroth.core.service.PersonalMemberService;
import vashion.azeroth.core.service.tran.PersonalDisburseService;

@Controller
@RequestMapping("tran")
public class QueryOrderController extends BaseController {
	
	@Autowired
	private PersonalDisburseService<PersonalDisburse> disburseService;
	@Autowired
	private PersonalMemberService<PersonalMember> memberService;
	
	
	@RequestMapping("queryOrder")
	@ResponseBody
	public ApiResult<List<PersonalDisburse>> queryOrder(PersonalDisburse disburse) {
		
		Integer status = OrderTransfer.orderStatusTransfer(disburse.getType());
		
		if(null == status) {
			return ApiResult.newErrorResult(TranErrorEnum.ORDER_TYPE_ERROR.getErrorCode(), "查询订单" + TranErrorEnum.ORDER_TYPE_ERROR.getErrorMessage());
		}
		
		if(status == 1000) {
			status = null;
		}
		
		return disburseService.queryOrder(disburse, status);
	}
	
	
	@RequestMapping("queryOrderByNo")
	@ResponseBody
	public ApiResult<List<PersonalDisburse>> queryOrderByNo(PersonalDisburse disburse) {
		
		return disburseService.queryOrderByNo(disburse);
	}

}
